//
//  SingleDetailViewController.m
//  MyDIYHouse
//
//  Created by dlios on 15-7-3.
//  Copyright (c) 2015年 李平洋. All rights reserved.
//

#import "SingleDetailViewController.h"
#import "SingleDetailTableViewCell.h"
#import "UIImageView+WebCache.h"

#define HEIGHT [UIScreen mainScreen].bounds.size.height
#define WIDTH [UIScreen mainScreen].bounds.size.width

@interface SingleDetailViewController ()<UITableViewDelegate, UITableViewDataSource>

@property(nonatomic, retain)UITableView *singelDetailTableView;

@end
@implementation SingleDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"商品";
    self.navigationController.navigationBar.barTintColor = [UIColor brownColor];
    
   // NSLog(@"%@",self.singleModel.title);
    
#pragma mark 创建tableView;
    self.singelDetailTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64 - 49 ) style:UITableViewStylePlain];
    self.singelDetailTableView.backgroundColor = [UIColor whiteColor];
    //设置无分割线
    self.singelDetailTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //设置代理人
    self.singelDetailTableView.delegate = self;
    self.singelDetailTableView.dataSource = self;
    [self.view addSubview:self.singelDetailTableView];
    [_singelDetailTableView release];
    

}
#pragma mark tableView协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuse = @"reuse";
    SingleDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[SingleDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse] autorelease];
    }
    
    
    [cell.CommodityImage sd_setImageWithURL:[NSURL URLWithString: self.singleModel.images[0]]];
    cell.CommodityNameLabel.text = self.singleModel.title;
    cell.dealerNameLabel.text = self.singleModel.store;
//    cell.addressIntroduceLabel.text = self.singleModel.address;
//    NSLog( @"%@",self.singleModel.addresses[6]);
    
    NSDictionary *addDic = [self.singleModel.addresses firstObject];
   // NSLog(@"%@",[addDic objectForKey:@"address"]);
    
    cell.phoneNameLabel.text = self.singleModel.phone;
    cell.addressIntroduceLabel.text =[addDic objectForKey:@"address"];

    return cell;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
